package org.jackysoft.controller;

import java.util.Collection;

import javax.annotation.Resource;
import javax.servlet.http.Part;

import org.jackysoft.controller.base.AbstractController;
import org.jackysoft.entity.Accessory;
import org.jackysoft.service.AttachmentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/attachment")
public class AttachmentController extends AbstractController<Accessory> {

	@Resource
	private AttachmentService service;

	@RequestMapping("/append")
	public void append(Part[] parts, @ModelAttribute long workflowId)
			throws Exception {

		service.create(parts, workflowId);

	}

	@RequestMapping("/start")
	public void start(@ModelAttribute long workflowId,
			@ModelAttribute Collection<Accessory> beans) throws Exception {
		
		beans = service.findByWorkflow(workflowId);
	}

	@RequestMapping("/remove")
	public void remove(@ModelAttribute Accessory bean,
			@ModelAttribute long workflowId) throws Exception {
		service.remove(bean, workflowId);

	}

}
